<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    //爬楼梯
    //1:1  2:2  3:3  4:3+2=5  5:5+3=8
    //第一步爬1个或者第一步爬2个
    //dp[i]=dp[i-1]+dp[i-2]
    function fn(n) {
        if (n <= 2) {
            return n
        }
        let dp = [1, 2]
        for (let i = 2; i < n; i++) {
            dp[i] = dp[i - 1] + dp[i - 2]
        }
        return dp[n - 1]
    }
    console.log(fn(10));

</script>

</html>